#include "StdAfx.h"
#include "Communicator.h"
#include <sstream>
#include <Windows.h>


Communicator::Communicator(void):currentTime(0)
{
	output.open("log.txt",ios::out);
	statsOnly.open("log_stats.txt", ios::out);

	SYSTEMTIME st;
	GetSystemTime(&st);
	
	output<<"Log z sieci kolejkowej. "<< st.wYear<<"-"<< st.wMonth <<"-"<< st.wDay << " "<< st.wHour + 1 <<":"<< st.wMinute<<":"<< st.wSecond << endl;
}

Communicator::Communicator( Communicator & com)
{
	output<<"Warning: Communicator used copy-constructor!"<<endl;
}


Communicator::~Communicator(void)
{
	output.close();
}

std::string Communicator::toString()
{
	priority_queue<MessageQ*,vector<MessageQ*>, MessageQ::greaterMessage > tq = messageQueue;
	ostringstream str;
	while(!tq.empty()){
		str << tq.top()->toString() << endl;	
		tq.pop();
	}

	return  str.str();	
}
